<template>
  <section class="table">
    <el-table
      :data="tableData"
      max-height="550"
      border
      align="center"
      :row-class-name="tableRowClassName"
      style="width: 100%"
    >
      <el-table-column align="center" label="序号">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ Number(scope.$index)+1 }}</span>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        v-for="(val,key) in tableLable"
        :key="key"
        :prop="key"
        :label="val"
      ></el-table-column>
    </el-table>
  </section>
</template>

<script>
export default {
  props: {
    tableLable: Object,
    tableData: Array,
    myself: ""
  },
  data() {
    return {};
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      //				console.log(row);
      //				console.log(rowIndex);
      if (row.hasOwnProperty("za_lyt_xm")) {
        //					console.log((this.tableData.length-1) + (this.tableData.length-2))
        let he = this.tableData.length - 1 + (this.tableData.length - 2);
        //					console.log(`和=${he}`)
        if (he < 9) {
          switch (rowIndex) {
            case 0:
              return "myself-row";
              break;
            case 1:
              return "myself-row";
              break;
            default:
              break;
          }
        } else {
          //						console.log('差='+(he -  (rowIndex + (rowIndex+1))))
          //						console.log('商='+(he -  (rowIndex + (rowIndex+1)))%8)/*规律数字8*/
          if (
            he == rowIndex + (rowIndex + 1) ||
            he == rowIndex + (rowIndex - 1)
          ) {
            return "myself-row";
          }
          if (
            (he - (rowIndex + (rowIndex + 1))) % 8 == 0 ||
            (he - (rowIndex + (rowIndex - 1))) % 8 == 0
          ) {
            return "myself-row";
          }
        }
      }
    }
  }
};
</script>

<style >
.table .el-table .myself-row {
  background: #f0f9eb;
}
</style>